/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "ImageContest", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "ImageContest.findAll", query = "SELECT i FROM ImageContest i"),
    @NamedQuery(name = "ImageContest.findByIdImgContest", query = "SELECT i FROM ImageContest i WHERE i.idImgContest = :idImgContest"),
    @NamedQuery(name = "ImageContest.findByInfoImage", query = "SELECT i FROM ImageContest i WHERE i.infoImage = :infoImage"),
    @NamedQuery(name = "ImageContest.findByImage", query = "SELECT i FROM ImageContest i WHERE i.image = :image"),
    @NamedQuery(name = "ImageContest.findByDate", query = "SELECT i FROM ImageContest i WHERE i.date = :date"),
    @NamedQuery(name = "ImageContest.findByIdContest", query = "SELECT i FROM ImageContest i WHERE i.idContest = :idContest")})
public class ImageContest implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IdImgContest", nullable = false)
    private Integer idImgContest;
    @Basic(optional = false)
    @Column(name = "InfoImage", nullable = false, length = 500)
    private String infoImage;
    @Basic(optional = false)
    @Column(name = "Image", nullable = false, length = 50)
    private String image;
    @Basic(optional = false)
    @Column(name = "Date", nullable = false, length = 50)
    private String date;
    @Basic(optional = false)
    @Column(name = "idContest", nullable = false)
    private int idContest;
    @JoinColumn(name = "IdRegUser", referencedColumnName = "IdRegUser", nullable = false)
    @ManyToOne(optional = false)
    private JoinContest joinContest;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "imageContest")
    private Collection<Vote> voteCollection;

    public ImageContest() {
    }

    public ImageContest(Integer idImgContest) {
        this.idImgContest = idImgContest;
    }

    public ImageContest(Integer idImgContest, String infoImage, String image, String date, int idContest) {
        this.idImgContest = idImgContest;
        this.infoImage = infoImage;
        this.image = image;
        this.date = date;
        this.idContest = idContest;
    }

    public Integer getIdImgContest() {
        return idImgContest;
    }

    public void setIdImgContest(Integer idImgContest) {
        this.idImgContest = idImgContest;
    }

    public String getInfoImage() {
        return infoImage;
    }

    public void setInfoImage(String infoImage) {
        this.infoImage = infoImage;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public int getIdContest() {
        return idContest;
    }

    public void setIdContest(int idContest) {
        this.idContest = idContest;
    }

    public JoinContest getJoinContest() {
        return joinContest;
    }

    public void setJoinContest(JoinContest joinContest) {
        this.joinContest = joinContest;
    }

    public Collection<Vote> getVoteCollection() {
        return voteCollection;
    }

    public void setVoteCollection(Collection<Vote> voteCollection) {
        this.voteCollection = voteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idImgContest != null ? idImgContest.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ImageContest)) {
            return false;
        }
        ImageContest other = (ImageContest) object;
        if ((this.idImgContest == null && other.idImgContest != null) || (this.idImgContest != null && !this.idImgContest.equals(other.idImgContest))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.ImageContest[idImgContest=" + idImgContest + "]";
    }

}
